const mixins = {
  computed:{
    isOffice(){
        return function(val = ''){
          return val.indexOf('office_')!=-1
        }
    },
    isMobile_new(){
      let flag = navigator.userAgent.match(/(phone|pad|pod|iPhone|iPod|ios|iPad|Android|Mobile|BlackBerry|IEMobile|MQQBrowser|JUC|Fennec|wOSBrowser|BrowserNG|WebOS|Symbian|Windows Phone)/i)
      return flag;
    }
  },
  methods: {
    getIcon(type,nameSuffix){
        let src = ""
        if(this.isOffice(type) || type=='document_upload'){
          if(["avi","wmv","mpg","mpeg","mov","rm","ram","swf","flv","mp4","mp3","wma","avi","rm","rmvb","flv","mpg","mkv"].indexOf(nameSuffix)!=-1){
            return '#keowledge-shipin'
          }
          switch((nameSuffix||"").toLocaleLowerCase()) {
            case 'knowledge': src = '#icon-morenwenjianjia';break;
            case 'directory': src = '#keowledge-wenjian';break;
            case 'doc':
            case 'docx':  src = '#keowledge-a-zu3558';break;
            case 'xls':
            case 'xlsx': src = '#keowledge-excel';break;
            case 'document_map': src ='#keowledge-naotu';break;
            case 'document_flow': src = '#keowledge-liucheng';break;
            case 'png':
            case 'jpg':
            case 'jpeg': src = '#keowledge-tupian';break;
            case 'txt': src = '#keowledge-TXT';break;
            case 'ppt':
            case 'pptx': src = '#keowledge-a-zu3556';break;
            case 'csv': src = '#keowledge-cvs';break;
            case 'pdf': src = '#keowledge-a-zu3557';break;
            case 'epub': src = '#keowledge-dianzishu';break;
            case 'svg': src = '#keowledge-svg';break;
            case 'rar':
            case 'arj':
            case 'z':
            case '7z':
            case 'cab':
            case 'zip': src= '#keowledge-yasuo';break;
            case 'vsdx': src= '#keowledge-visio';break;
            case 'ofd': src= '#keowledge-ofd';break;
            default: src = '#keowledge-weizhi';break;
          }
        }else{
          switch(type) {
            case 'knowledge': src = '#keowledge-quanbuwenku-xuanzhong';break;
            case 'directory': src = '#keowledge-wenjian';break;
            case 'document_html': src = '#keowledge-a-zu3554';break;
            case 'document_xlsx': src = '#keowledge-a-zu3555';break;
            case 'document_map': src = '#keowledge-naotu';break;
            case 'document_flow': src = '#keowledge-liucheng';break;
            case 'document_image': src = '#keowledge-tupian';break;
            case 'document_txt': src = '#keowledge-TXT';break;
            case 'document_ppt': src = '#keowledge-ppt';break;
            case 'document_unrecognized': src = '#keowledge-weizhi';break;
            case 'url_address': src = '#keowledge-URL';break;
            case 'md': src = '#keowledge-MAK';break;
            case 'xmind': src = '#keowledge-xmind';break;
            default: src = '#keowledge-wenjian';break;
          }
        }
        return src
    },
    getPng(type,nameSuffix){
      let src = ""
      if(this.isOffice(type) || type=='document_upload'){
        if(["cda","wav","mp3","aif","aiff","mid","wma","ra","vqf","ape"].indexOf(nameSuffix)!=-1){
          return 'mp3'
        }
        if(["avi","wmv","mpg","mpeg","mov","rm","ram","swf","flv","mp4","avi","rm","rmvb","flv","mpg","mkv"].indexOf(nameSuffix)!=-1){
          return 'keowledge-shipin'
        }
        switch((nameSuffix||"").toLocaleLowerCase()) {
          case 'knowledge': src = 'knowledge';break;
          case 'directory': src = 'wenjianjia';break;
          case 'doc':
          case 'docx':  src = 'word';break;
          case 'xls':
          case 'xlsx': src = 'keowledgeExcel';break;
          case 'document_map': src ='map';break;
          case 'document_flow': src = 'keowledgeLiucheng';break;
          case 'gif': src = 'gif';break;
          case 'png':
          case 'jpg':
          case 'jpeg': src = 'keowledgeTupian';break;
          case 'txt': src = 'text';break;
          case 'ppt':
          case 'pptx': src = 'keowledgePpt';break;
          case 'csv': src = 'csv';break;
          case 'pdf': src = 'keowledgePdf';break;
          case 'epub': src = 'keowledgeDianzishu';break;
          case 'svg': src = 'svg';break;
          case 'rar':
          case 'arj':
          case 'z':
          case '7z':
          case 'cab':
          case 'zip': src= 'keowledgeYasuo';break;
          case 'dwg':
          case 'dxf':
          case 'dws':
          case 'dwt': src= 'cad';break;
          case 'psd': src= 'ps';break;
          case 'vsdx': src= 'vis';break;
          case 'ofd': src= 'ofd';break;
          default: src = 'keowledgeWeizhi';break;
        }
      }else{
        switch(type) {
          case 'knowledge': src = 'knowledge';break;
          case 'directory': src = 'wenjianjia';break;
          case 'document_html': src = 'iconTxt';break;
          case 'document_xlsx': src = 'luckysheet';break;
          case 'document_map': src = 'map';break;
          case 'document_flow': src = 'keowledgeLiucheng';break;
          case 'document_image': src = 'keowledgeTupian';break;
          case 'document_txt': src = 'iconTxt';break;
          case 'document_ppt': src = 'keowledgePpt';break;
          case 'document_unrecognized': src = 'keowledgeWeizhi';break;
          case 'url_address': src = 'keowledgeURL';break;
          case 'md': src = 'md';break;
          case 'xmind': src = 'keowledgeXMIND';break;
          default: src = 'wenjianjia';break;
        }
      }
      return src
    },
    getRPng(type,nameSuffix){
      let src = ""
      if(this.isOffice(type) || type=='document_upload'){
        if(["cda","wav","mp3","aif","aiff","mid","wma","ra","vqf","ape"].indexOf(nameSuffix)!=-1){
          return 'mp3'
        }
        if(["avi","wmv","mpg","mpeg","mov","rm","ram","swf","flv","mp4","avi","rm","rmvb","flv","mpg","mkv"].indexOf(nameSuffix)!=-1){
          return 'video'
        }
        switch((nameSuffix||"").toLocaleLowerCase()) {
          case 'directory': src = 'floder';break;
          case 'doc':
          case 'docx':  src = 'word';break;
          case 'xls':
          case 'xlsx': src = 'excel';break;
          case 'document_map': src ='map';break;
          case 'document_flow': src = 'flow';break;
          case 'gif': src = 'gif';break;
          case 'png':
          case 'jpg':
          case 'jpeg': src = 'image';break;
          case 'txt': src = 'text';break;
          case 'ppt':
          case 'pptx': src = 'ppt';break;
          case 'csv': src = 'csv';break;
          case 'pdf': src = 'pdf';break;
          case 'epub': src = 'epub';break;
          case 'svg': src = 'svg';break;
          case 'rar':
          case 'arj':
          case 'z':
          case '7z':
          case 'cab':
          case 'zip': src= 'zip';break;
          case 'dwg':
          case 'dxf':
          case 'dws':
          case 'dwt': src= 'cad';break;
          case 'psd': src= 'psd';break;
          case 'vsdx': src= 'vis';break;
          case 'ofd': src= 'ofd';break;
          default: src = 'none';break;
        }
      }else{
        switch (type) {
          case 'document_html': src = 'html';break;
          case 'document_xlsx': src = 'luckysheet';break;
          case 'document_map': src = 'map';break;
          case 'document_flow': src = 'flow';break;
          case 'document_image': src = 'image';break;
          case 'document_txt': src = 'text';break;
          case 'document_ppt': src = 'ppt';break;
          case 'document_unrecognized': src = 'none';break;
          case 'url_address': src = 'url';break;
          case 'md': src = 'md';break;
          case 'xmind': src = 'xmind';break;
          default: src = 'floder'; break;
        }
      }
      return src
    },
    $superWidth(){
      if(this.getStoreKonwledgeInfo?.otherJson){
        let otherJson = JSON.parse(this.getStoreKonwledgeInfo.otherJson)
        return !otherJson.superWidth
      }else{
        return false
      }
    }
  },
}

export default mixins